package cn.kgc.ffzw.day21.homework;

import java.util.*;

public class LinkedListTest {
    public static void main(String[] args) {
        LinkedList list=new LinkedList();
        Orders orders=new Orders();
        orders.setId(1);
        orders.setName("大白菜烧肉");
        orders.setCount(3);
        orders.setPrice(22);
        orders.setAddress("小行路1号");
        list.add(orders);

        orders.setId(1);
        orders.setName("大白菜烧肉");
        orders.setCount(3);
        orders.setPrice(22);
        orders.setAddress("小行路1号");
        list.add(orders);

        Orders orders1=new Orders();

        orders1.setId(2);
        orders1.setName("土豆烧肉");
        orders1.setCount(4);
        orders1.setPrice(44);
        orders1.setAddress("小行路2号");
        list.add(orders1);

        orders1.setId(2);
        orders1.setName("土豆烧肉");
        orders1.setCount(4);
        orders1.setPrice(44);
        orders1.setAddress("小行路2号");
        list.add(orders1);

        System.out.println(list);

        HashSet set = new HashSet<>();
        set.addAll(list);
        list.clear();
        list.addAll(set);
        System.out.println("去重后"+list);


        ArrayList alist=new ArrayList();
        alist.addAll(list);
        System.out.println("ArrayList遍历");
        for (Object obj:alist
             ) {
            System.out.println(obj);

        }

        alist.add(new Orders());//增
        alist.remove(1);//删
        alist.set(1,alist.get(0));//改
        System.out.println(alist.get(1));//查

        System.out.println("___________________________________");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("___________________________________");
        for (Object obj: list
             ) {
            System.out.println(obj);
        }
        System.out.println("___________________________________");


        Iterator iterator=list.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }

    }
}
